package com.lesama.map;

import java.util.Map;
import java.util.TreeMap;

public class MapTest1 {
    public static void main(String[] args) {
        String s = "absadbasdbkjhfdsa";
        System.out.println(s.length());
        Map<Character, Integer> countMap = new TreeMap<>();
        for (int i = 0; i < s.length(); i++) {
            if(!countMap.containsKey(s.charAt(i))) {
                countMap.put(s.charAt(i), 1);
            } else {
                countMap.put(s.charAt(i), countMap.get(s.charAt(i)) + 1);
            }
        }

        StringBuilder sb = new StringBuilder();
        countMap.forEach((key, value) -> sb.append(key).append("(").append(value).append(")"));
        System.out.println(sb.toString());
    }
}
